package com.zmn.brs.task.listenter;

import com.alibaba.fastjson.JSONObject;
import com.zmn.brs.business.interfaces.record.OperateRecordBService;
import com.zmn.brs.common.constant.BrsMqConst;
import com.zmn.brs.common.model.mq.StaffOperateRecordMq;
import com.zmn.manager.mq.annotation.AliyunMQHandler;
import com.zmn.manager.mq.annotation.AliyunMQListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 类描述：员工操作记录消息监听
 *
 * @author xujie
 * @since 2021/03/15 16:31
 */

@Slf4j
@Component
@AliyunMQListener(topic = "${spring.mq.topic.brs}")
public class StaffOperateRecordMessageQueueListener {

    final static String TAG = "员工操作记录消息监听";

    @Resource
    OperateRecordBService operateRecordBusinessService;

    @AliyunMQHandler(topic = "${spring.mq.topic.brs}", tags = BrsMqConst.STAFF_OPERATE_RECORD_MESSAGE)
    public void staffOperateRecord(String message) {

        StaffOperateRecordMq recordMq = JSONObject.parseObject(message, StaffOperateRecordMq.class);
        log.info("[{}],接收到新的消息message:{}", TAG, recordMq);
        operateRecordBusinessService.eventTriggering(recordMq);
    }
}
